#pragma once


std::string opers = "+-*/%";

enum
{
    DivZero = 1,
    ModZero,
    UnKnow
};

class task
{
public:
    task()
    {}
    task(int data1,int data2,char oper)
    :data1_(data1),data2_(data2),oper_(oper),exitcode_(0),result_(0)
    {}

    ~task(){}

    void operator()()
    {
        run();
    }

    std::string getTask()
    {
        std::string ret = std::to_string(data1_);
        ret += oper_;
        ret += std::to_string(data2_);
        ret += "的结果是？？ ";
        return ret;
    }

    std::string getResult()
    {
        std::string ret = std::to_string(data1_);
        ret += oper_;
        ret += std::to_string(data2_);
        ret += '=';
        ret += std::to_string(result_);
        ret += "   code:[ ";
        ret += std::to_string(exitcode_);
        ret += " ]";
        return ret;
    }



private:
    void run()
    {
        switch(oper_)
        {
            case '+':
                result_ = data1_ + data2_;
                break;
            case '-':
                result_ = data1_ - data2_;
                break;
            case '*':
                result_ = data1_ * data2_;
                break;
            case '/':
                if(data2_ == 0) exitcode_ = DivZero;
                else result_ = data1_ / data2_;
                break;
            case '%':
                if(data2_ == 0) exitcode_ = ModZero;
                else result_ = data1_ % data2_;
                break;
            default:
                exitcode_ = UnKnow;
                break;
        }
    }

private:


    int data1_;
    int data2_;
    char oper_;

    int result_;
    int exitcode_;
};